<%@ page pageEncoding="ISO-8859-1" contentType="text/html; charset=ISO-8859-1" %>
<%@ page isELIgnored="false" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt" %>
<script type="text/javascript" src="scripts/defscripts.js"></script>
<fmt:setBundle basename="MessageResources"/>

<form name="elementForm" method="post" action="${param['formAction']}">
	<table border="0" cellpadding="1" align="center">
		<tr>
			<td align="right"><fmt:message key="treatment.description"/>:</td>
			<td><input name="element.description" type="text" size="30" value="${element.description}"></td>
		</tr>
		<tr>
			<td align="right" valign="top"><fmt:message key="treatment.disease"/>:</td>
			<td>
				<select name="diseasesCombo" id="diseasesCombo">
					<option value="null"><fmt:message key="treatment.disease.select"/>
					<c:forEach items="${diseaseList}" var="eachDisease">
						<option value="${eachDisease.id}">${eachDisease.name}
					</c:forEach>
				</select>
			</td>
		</tr>
		<tr>
			<td align="right" valign="top"><fmt:message key="treatment.behaviors"/>:</td>
			<td>
				<input name="behaviorsComboListSize" type="hidden" id="behaviorsComboListSize" value="0">
				<select name="sourceCombo1" id="sourceCombo1" style="display:none">
					<option value="null"><fmt:message key="treatment.behaviors.select"/>
					<c:forEach items="${behaviorList}" var="eachBehavior">
						<option value="${eachBehavior.id}">${eachBehavior.name}
					</c:forEach>
				</select>
				<div id="behaviorsComboList"></div>
				<input name="addBehaviorButton" type="button" value="<fmt:message key='treatment.register.form.addBehaviorButton.label'/>" onclick="addCombo2('behaviorsComboList','behaviorsCombo','sourceCombo1','behaviorsComboListSize')">
				<script type="text/javascript">
					for (i = 0; i < 3; i++) document.elementForm.addBehaviorButton.click();
					<c:forEach items="${element.behaviors}" var="eachBehavior" varStatus="eachId">
						if (${eachId.count - 1} >= document.elementForm.behaviorsComboListSize.value) document.elementForm.addBehaviorButton.click();
						document.elementForm.behaviorsCombo${eachId.count - 1}.value = ${eachBehavior.id};
					</c:forEach>
				</script>
			</td>
		</tr>
		<tr>
			<td align="right" valign="top"><fmt:message key="treatment.drugs"/>:</td>
			<td>
				<input name="drugsComboListSize" type="hidden" id="drugsComboListSize" value="0">
				<select name="sourceCombo2" id="sourceCombo2" style="display:none">
					<option value="null"><fmt:message key="treatment.drugs.select"/>
					<c:forEach items="${drugList}" var="eachDrug">
						<option value="${eachDrug.id}">${eachDrug.scientificName} --- ${eachDrug.commercialName}
					</c:forEach>
				</select>
				<div id="drugsComboList"></div>
				<input name="addDrugButton" type="button" value="<fmt:message key='treatment.register.form.addDrugButton.label'/>" onclick="addCombo2('drugsComboList','drugsCombo','sourceCombo2','drugsComboListSize')">
				<script type="text/javascript">
					for (i = 0; i < 3; i++) document.elementForm.addDrugButton.click();
					<c:forEach items="${element.drugs}" var="eachDrug" varStatus="eachId">
						if (${eachId.count - 1} >= document.elementForm.drugsComboListSize.value) document.elementForm.addDrugButton.click();
						document.elementForm.drugsCombo${eachId.count - 1}.value = ${eachDrug.id};
					</c:forEach>
				</script>
			</td>
		</tr>
		<tr>
			<td align="right" valign="top"><fmt:message key="treatment.foods"/>:</td>
			<td>
				<input name="foodsComboListSize" type="hidden" id="foodsComboListSize" value="0">
				<select name="sourceCombo3" id="sourceCombo3" style="display:none">
					<option value="null"><fmt:message key="treatment.foods.select"/>
					<c:forEach items="${foodList}" var="eachFood">
						<option value="${eachFood.id}">${eachFood.name}
					</c:forEach>
				</select>
				<div id="foodsComboList"></div>
				<input name="addFoodButton" type="button" value="<fmt:message key='treatment.register.form.addFoodButton.label'/>" onclick="addCombo2('foodsComboList','foodsCombo','sourceCombo3','foodsComboListSize')">
				<script type="text/javascript">
					for (i = 0; i < 3; i++) document.elementForm.addFoodButton.click();
					<c:forEach items="${element.foods}" var="eachFood" varStatus="eachId">
						if (${eachId.count - 1} >= document.elementForm.foodsComboListSize.value) document.elementForm.addFoodButton.click();
						document.elementForm.foodsCombo${eachId.count - 1}.value = ${eachFood.id};
					</c:forEach>
				</script>
			</td>
		</tr>
		<tr>
			<td colspan="2" align="center">
				<input name="submit" type="submit" value="<fmt:message key='element.form.submit.label'/>">
				<input name="clear" type="reset" value="<fmt:message key='element.form.clear.label'/>">
				<input name="back" type="button" value="<fmt:message key='element.form.back.label'/>" onclick="location.href='${backPage}'">
			</td>
		</tr>
	</table>
</form>
